<?php

declare(strict_types=1);

namespace App\AdminApi\Modular\Administer\Validate;

use Zms\Validate\ValidateAbstract;

/**
 * 后台角色验证器
 */
class RoleValidate extends ValidateAbstract
{
    public function rules(): array
    {
        return [
            ['id', 'required', 'error' => '数据异常，请刷新重试', 'on' => ['updated']],
            ['id', 'number', 'error' => '数据异常，请刷新重试', 'on' => ['updated']],

            ['name', 'required', 'error' => '请输入{label}', 'on' => ['created', 'updated']],
            ['name', 'string', 'max' => 10, 'error' => '{label}错误', 'on' => ['created', 'updated']],

            ['auth', 'required', 'error' => '请选择{label}', 'on' => ['created', 'updated']],
            ['auth', 'list', 'error' => '{label}数据错误', 'on' => ['created', 'updated']],

            ['remarks', 'string', 'max' => 30, 'on' => ['created', 'updated']],

            ['status', 'in', 'enums' => [0, 1], 'on' => ['created', 'updated']]
        ];
    }


    public function labels(): array
    {
        return [
            'name' => '角色名称',
            'auth' => '角色权限',
            'label' => '数据权限',
            'remarks' => '备注说明',
            'status' => '角色状态'
        ];
    }
}